package com.yunban.project.message.controller;

import com.yunban.project.message.dto.CSMessageReq;
import com.yunban.project.message.resp.CSMessageResp;
import com.yunban.project.message.service.CSMessageService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import net.lab1024.sa.base.common.annoation.NoNeedLogin;
import net.lab1024.sa.base.module.support.operatelog.annotation.OperateLog;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author: lijiajun
 * @date: 2025-03-07
 * @version: 1.0
 */
@OperateLog
@RestController
@Tag(name = "客服消息管理")
@RequestMapping("/cs-message-api")
public class CSMessageController {

    @Resource
    private CSMessageService csMessageService;

    @NoNeedLogin
    @PostMapping("/send")
    @Operation(summary = "发送消息")
    Boolean sendMessage(@RequestBody @Validated CSMessageReq req) {
        return this.csMessageService.send(req);
    }

    @PostMapping("/reply")
    @Operation(summary = "回复消息")
    Boolean reply(@RequestBody @Validated CSMessageReq req) {
        return this.csMessageService.reply(req);
    }

    @NoNeedLogin
    @GetMapping("/list")
    @Operation(summary = "根据会话ID获取消息列表")
    List<CSMessageResp> getMessageList(@RequestParam("sessionId") String sessionId) {
        return this.csMessageService.findBySessionId(sessionId);
    }
}
